﻿using DotNetCore.CAP;
using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CAP.Core.IntegrationEvents
{
    public class SubscriberService : ICapSubscribe
    {
        public SubscriberService()
        {

        }

        [CapSubscribe("user.created")]
        public async Task UserCreated(UserCreatedEvent @event)
        {
            //throw new Exception();
            Console.WriteLine("已消费：CAP.Core.UserCreated");
        }


        // 消费者 - 同一个GroupName确保只有一个消费者实例处理
        [CapSubscribe("user.updated", Group = "user.updated.processor")]
        public async Task UserUpdated(UserCreatedEvent @event)
        {
            // 只有一个消费者实例会执行这个处理
            Console.WriteLine("已消费：CAP.Core.UserCreated");
        }
    }
}
